package columnEditors;
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
 
@SuppressWarnings("serial")
public class CheckBoxRenderer extends JCheckBox implements TableCellRenderer {
 
	public CheckBoxRenderer() {
		setOpaque(true);
	}
  
	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {

		if (isSelected) {
			this.setBackground(table.getSelectionBackground());
			this.setForeground(table.getSelectionForeground());
		}
		else {
			this.setBackground(table.getBackground());
			this.setForeground(table.getForeground());
		}
		
		boolean marked = value == null ? false : (Boolean)value;
		if (marked) {
			this.setSelected(true);
		}
		else
			this.setSelected(false);

		return this;
	}
}
